package com.catchu.pattern.creational.原型模式;

import java.util.Date;

/**
 * 销售单
 */
public class SalesOrder extends Order {

    /**
     * 商品名称
     */
    private String productName;

    /**
     * 采购数量
     */
    private int count;

    /**
     * 单价
     */
    private float unitPrice;

    public SalesOrder(Order order,String productName, int count, float unitPrice) {
        super(order.getId(),order.getCreateTime(),order.getCreator(),order.getType());
        this.productName = productName;
        this.count = count;
        this.unitPrice = unitPrice;
    }

    public SalesOrder(String id, Date createTime, String creator, String type, String productName, int count, float unitPrice) {
        super(id, createTime, creator, type);
        this.productName = productName;
        this.count = count;
        this.unitPrice = unitPrice;
    }

    @Override
    protected SalesOrder clone() throws CloneNotSupportedException {
        SalesOrder salesOrder = new SalesOrder(super.clone(),productName,count,unitPrice);
        return salesOrder;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public float getUnitPrice() {
        return unitPrice;
    }

    public void setUnitPrice(float unitPrice) {
        this.unitPrice = unitPrice;
    }

    @Override
    public String toString() {
        return "SalesOrder{" + super.toString()+
                "productName='" + productName + '\'' +
                ", count=" + count +
                ", unitPrice=" + unitPrice +
                '}';
    }
}
